package homework02;

import java.io.*;
import java.util.HashMap;
import java.util.Scanner;

public class ReaderDemo {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        try {
            BufferedReader br=new BufferedReader(new FileReader("F:\\IJ\\Text02\\HomeWork1016\\doc\\worldcup.txt"));
            HashMap<String,String> list = new HashMap<>();
            String[] ch = new String[2];
            String str2;
            str2 = br.readLine();
            while(str2 != null) {
                ch = str2.split("/");
                list.put(ch[0], ch[1]);
                str2 = br.readLine();
            }
            br.close();
            System.out.print("请输入世界杯的年份：");
            String year=input.next();
            int a = 0;
            for(String str:list.keySet()) {
                if(year.equals(str)) {
                    a ++;
                            break;
                }
            }
            if(a == 0) {
                System.out.println("该年份没有举办世界杯！");
            }else {
                System.out.println(year+"的世界杯冠军为：" + list.get(year));
            }
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}
